package top.wangjiu.java.jvm.attribute.info;

import top.wangjiu.java.jvm.constantinfo.ConstantPoolInfo;

public class LocalVariableInfo {

    private final short startPc;
    private final short length;
    private final short nameIndex;
    private final short descriptorIndex;
    private final short index;

    public LocalVariableInfo(short startPc, short length, short nameIndex, short descriptorIndex, short index){
        this.startPc = startPc;
        this.length = length;
        this.nameIndex = nameIndex;
        this.descriptorIndex = descriptorIndex;
        this.index = index;
    }

    public String toString(ConstantPoolInfo[] poolInfos) {
        return "{" +
                "startPc:" + startPc +
                ",length:" + length +
                ",slot:" + index +
                ",name:" + poolInfos[nameIndex].toString(poolInfos) +
                ",Signature:" + poolInfos[descriptorIndex].toString(poolInfos) +
                '}';
    }
}
